package com.heima.feigns.fallback;

import com.heima.feigns.WemediaFeign;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.wemedia.pojos.WmNews;
import com.heima.model.wemedia.pojos.WmUser;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @package com.heima.feigns.fallback
 * @Date 2022/2/27
 * @project heima-leadnews
 */
@Component
@Slf4j
public class WemediaFeignFallback implements FallbackFactory<WemediaFeign> {
    @Override
    public WemediaFeign create(Throwable throwable) {
        return new WemediaFeign() {
            @Override
            public ResponseResult<WmUser> insertWmUser(WmUser wmUser) {
                log.error("参数，，，{}",wmUser);
                log.error("自媒体保存save方法失败 {}",throwable.getMessage());
                return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
            }

            @Override
            public ResponseResult<WmUser> selectByName(String name) {
                log.error("参数，，，{}",name);
                log.error("自媒体查询方法失败 {}",throwable.getMessage());
                return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
            }

            @Override
            public ResponseResult updateWmnews(WmNews wmNews) {
                log.error("参数，，，{}",wmNews);
                log.error("自媒体修改方法失败 {}",throwable.getMessage());
                return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);

            }

            @Override
            public ResponseResult<WmNews> selectOne(Integer id) {
                log.error("参数，，，{}",id);
                log.error("自媒体查询方法失败 {}",throwable.getMessage());
                return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);

            }
        };
    }
}
